import Vue from 'vue'

// 重置默认的css样式
import 'normalize.css/normalize.css'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 引入elementUI语言包,做国际化多语言切换，引入了英文语言包
// import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

// 测试引入自定义语言包
// import i19n from './lang'
// Vue.use(i19n, 'en')

// 全局的css引入
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

// 全局混入检查按钮权限方法
import checkPermission from './mixin/checkPermission'
Vue.mixin(checkPermission)

// 引入自定义插件
import Component from './components'
Vue.use(Component)

// 注册全局过滤器
import * as filters from './filters'
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// 引入svgIcon
import '@/icons' // icon
// 引入权限控制
import '@/permission' // permission control

// 一次性引入对象中所有变量，用一个变量来接收
import * as directives from './directives'
// 通过Object.keys方法取出对象中所有key值
// 并对key值进行循环遍历，一次性注册所有的全局指令
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

  const { mockXHR } = require('../mock')
  mockXHR()

// set ElementUI lang to EN
// 设置多语言包
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

import i18n from './lang'
// 设置element为当前的语言
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
